//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
import touchRipple from '../internal/touchRipple'
export default {
name: 'mu-switch',
props: {
name: {
type: String
},
value: {
type: Boolean
},
label: {
type: String,
default: ''
},
labelLeft: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
}
},
data () {
return {
inputValue: this.value
}
},
watch: {
value (val) {
this.inputValue = val
},
inputValue (val) {
this.$emit('input', val)
}
},
methods: {
handleMouseDown (event) {
if (this.disabled) return
if (event.button === 0) {
this.$children[0].start(event)
}
},
handleClick () {
// 阻止事件冒泡,放置外部控制的时候触发两次 click
},
handleMouseUp () {
if (this.disabled) return
this.$children[0].end()
},
handleMouseLeave () {
if (this.disabled) return
this.$children[0].end()
},
handleTouchStart (event) {
if (this.disabled) return
this.$children[0].start(event)
},
handleTouchEnd () {
if (this.disabled) return
this.$children[0].end()
},
handleChange () {
this.$emit('change', this.inputValue)
}
},
components: {
'touch-ripple': touchRipple
}
}
|